﻿// -----------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.Composition.ReflectionModel;
using System.Globalization;
using System.Reflection;
using Microsoft.Internal;
using Microsoft.Internal.Collections;

namespace System.ComponentModel.Composition.AttributedModel
{
    internal class AttributedMemberImportDefinition : AttributedImportDefinition
    {
        private readonly ReflectionWritableMember _member;

        public AttributedMemberImportDefinition(AttributedComposablePartDefinition definition, MemberInfo member)
            : this(definition, member.ToReflectionWritableMember(), member)
        {
        }

        private AttributedMemberImportDefinition(AttributedComposablePartDefinition definition, ReflectionWritableMember member, ICustomAttributeProvider attributeProvider)
            : base(definition, member, attributeProvider)
        {
            this._member = member;
        }

        public override bool IsPrerequisite
        {
            get { return false; }
        }

        public override ImportingItem ToImportingItem()
        {
            return new ImportingMember(this, this._member);
        }

        protected override string GetDisplayName()
        {
            return string.Format(
                CultureInfo.CurrentCulture,
                "{0} (ContractName=\"{1}\")",    // NOLOC
                this._member.DisplayName,
                this.ContractName);
        }
    }
}
